import React, { useRef,useState,useEffect } from 'react';

function Example(){
    const ipt = useRef(null);
    const iptV = useRef(null)
    const [txt,setTxt] = useState("")
    const clickHandle = (e)=>{
        ipt.current.value = "天降降价大任于斯人也"
        console.log()
    }
    useEffect(()=>{
        console.log("txt changed")
    },[txt])
    const changeIpt = (e)=>{
        console.log(iptV.current.value)
        setTxt(iptV.current.value)
        // setTxt(e.target.value)
    }
    return (<>
        <input ref={ipt}/>
        <button onClick={ clickHandle }>change input</button>
        <hr/>
        <input value={ txt } ref={ iptV } onChange={(e)=>changeIpt(e)} />
    </>)
}
export default Example